Web Redirect using Subdomain
The following webserver configs can be used as redirects to GitLab for use as Go module names. Example:
user.DOMAIN.TLD/project
->OTHER_DOMAIN.TLD/user/project
DOMAIN.TLD/user/project
->OTHER_DOMAIN.TLD/user/project
Nginx
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name
~^(?<subdomain>.+)\.DOMAIN\.TLD
DOMAIN.TLD
;
ssl_certificate ../fullchain.cer;
ssl_certificate_key ../DOMAIN.TLD.key;
set $subdomain_redirect false;
if ( $host != "DOMAIN.TLD" ) {
set $subdomain_redirect true;
}
if ( $subdomain_redirect = true ) {
return 302 https://OTHER_DOMAIN.TLD/$subdomain$request_uri;
}
return 302 https://OTHER_DOMAIN.TLD$request_uri;
}
HAProxy
frontend ft_https
mode http
bind *:443 ssl crt /usr/local/etc/haproxy/certs/
# http proxy
use_backend bk_gitlab_redirect if { hdr(host) -i DOMAIN.TLD }
use_backend bk_gitlab_redirect if { hdr(host) -m end DOMAIN.TLD }
backend bk_gitlab_redirect
mode http
acl is_domain hdr(host) -i DOMAIN.TLD
http-request redirect code 302 prefix https://OTHER_DOMAIN.TLD if is_domain
http-request redirect code 302 prefix https://OTHER_DOMAIN.TLD/%[hdr(host),lower,regsub(\.DOMAIN\.TLD$,)] unless is_domain
Custom Go Server
Vanity Domain and Avatar API for GitLab: https://dev.rievo.net/rievo/dev-api